From 04bc76f8b16ced1335e1825fb1cd164342e3387b Mon Sep 17 00:00:00 2001 From: =?utf8?q?=D0=A1=D1=83=D1=85=D0=B0=D1=80=D0=B8=D0=BA?= Date: Sat, 24 Jan 2015 11:16:54 +0300 Subject: [PATCH] update to recent rust changes: part #2 --- Cargo.lock | 25 +++++++++++++------------ src/cargo/core/package_id.rs | 13 ++++++++----- src/cargo/util/errors.rs | 24 ++++++++++++++++++------ 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b02ee8715..c6832f1d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = "0.1.0" dependencies = [ "advapi32-sys 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "curl 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", - "docopt 0.6.30 (registry+https://github.com/rust-lang/crates.io-index)", + "docopt 0.6.31 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.0 (git+https://github.com/carllerche/hamcrest-rust.git)", "log 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -15,9 +15,9 @@ dependencies = [ "semver 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", - "url 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "url 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -41,7 +41,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curl-sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", - "url 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "url 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -57,7 +57,7 @@ dependencies = [ [[package]] name = "docopt" -version = "0.6.30" +version = "0.6.31" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "regex 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -79,12 +79,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "git2" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "url 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "url 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -112,7 +112,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libgit2-sys" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libssh2-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -227,10 +227,11 @@ dependencies = [ [[package]] name = "time" -version = "0.1.12" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -243,7 +244,7 @@ dependencies = [ [[package]] name = "url" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/src/cargo/core/package_id.rs b/src/cargo/core/package_id.rs index 5f78233eb..9d999890f 100644 --- a/src/cargo/core/package_id.rs +++ b/src/cargo/core/package_id.rs @@ -89,15 +89,18 @@ pub enum PackageIdError { impl Error for PackageIdError { fn description(&self) -> &str { "failed to parse package id" } - fn detail(&self) -> Option { - Some(match *self { +} + +impl fmt::Display for PackageIdError { + fn fmt(self, f: fmt::Formatter) { + match self { PackageIdError::InvalidVersion(ref v) => { - format!("invalid version: {}", *v) + write!(f, "invalid version: {}", *v) } PackageIdError::InvalidNamespace(ref ns) => { - format!("invalid namespace: {}", *ns) + write!(f, "invalid namespace: {}", *ns) } - }) + } } } diff --git a/src/cargo/util/errors.rs b/src/cargo/util/errors.rs index 041da8f07..32f65372a 100644 --- a/src/cargo/util/errors.rs +++ b/src/cargo/util/errors.rs @@ -36,7 +36,6 @@ impl fmt::Debug for Box { impl Error for Box { fn description(&self) -> &str { (**self).description() } - fn detail(&self) -> Option { (**self).detail() } fn cause(&self) -> Option<&Error> { (**self).cause() } } @@ -89,7 +88,12 @@ impl ChainError for Option { impl Error for ChainedError { fn description(&self) -> &str { self.error.description() } - fn detail(&self) -> Option { self.error.detail() } +} + +impl fmt::Display for ChainedError { + fn fmt(&self, f: fmt::Formatter) { + fmt::Display::fmt(self.error, f) + } } impl CargoError for ChainedError { @@ -109,7 +113,6 @@ pub struct ProcessError { impl Error for ProcessError { fn description(&self) -> &str { self.desc.as_slice() } - fn detail(&self) -> Option { None } fn cause(&self) -> Option<&Error> { self.cause.as_ref().map(|s| s as &Error) } @@ -149,7 +152,6 @@ impl fmt::Debug for ConcreteCargoError { impl Error for ConcreteCargoError { fn description(&self) -> &str { self.description.as_slice() } - fn detail(&self) -> Option { self.detail.clone() } fn cause(&self) -> Option<&Error> { self.cause.as_ref().map(|c| &**c) } @@ -168,10 +170,15 @@ pub struct Human(pub E); impl Error for Human { fn description(&self) -> &str { self.0.description() } - fn detail(&self) -> Option { self.0.detail() } fn cause(&self) -> Option<&Error> { self.0.cause() } } +impl fmt::Display for Human { + fn fmt(self, f: fmt::Formatter) { + fmt::Display::fmt(self.0, f) + } +} + impl CargoError for Human { fn is_human(&self) -> bool { true } fn cargo_cause(&self) -> Option<&CargoError> { self.0.cargo_cause() } @@ -191,10 +198,15 @@ pub struct CliError { impl Error for CliError { fn description(&self) -> &str { self.error.description() } - fn detail(&self) -> Option { self.error.detail() } fn cause(&self) -> Option<&Error> { self.error.cause() } } +impl fmt::Display for CliError { + fn fmt(self, f: fmt::Formatter) { + fmt::Display::fmt(self.error, f) + } +} + impl CliError { pub fn new(error: S, code: u32) -> CliError { let error = human(error.as_slice().to_string()); -- 2.30.2